
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 06/19/2013 14:01:34
-- Generated from EDMX file: C:\Users\Ferna\Documents\Visual Studio 2012\Projects\OL4RENTA\DataModel\Model.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [OL4RENT];
GO
IF SCHEMA_ID(N'mobileS') IS NULL EXECUTE(N'CREATE SCHEMA [mobileS]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[mobileS].[FK_GoodAttribute]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[AttributeSet] DROP CONSTRAINT [FK_GoodAttribute];
GO
IF OBJECT_ID(N'[mobileS].[FK_SiteAttributeAttribute]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[AttributeSet] DROP CONSTRAINT [FK_SiteAttributeAttribute];
GO
IF OBJECT_ID(N'[mobileS].[FK_GoodContent]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[ContentSet] DROP CONSTRAINT [FK_GoodContent];
GO
IF OBJECT_ID(N'[mobileS].[FK_UserContent]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[ContentSet] DROP CONSTRAINT [FK_UserContent];
GO
IF OBJECT_ID(N'[mobileS].[FK_GoodLike]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[LikeSet] DROP CONSTRAINT [FK_GoodLike];
GO
IF OBJECT_ID(N'[mobileS].[FK_UserSetLikeSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[LikeSet] DROP CONSTRAINT [FK_UserSetLikeSet];
GO
IF OBJECT_ID(N'[mobileS].[FK_SiteGood]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[GoodSet] DROP CONSTRAINT [FK_SiteGood];
GO
IF OBJECT_ID(N'[mobileS].[FK_SiteSiteAttribute]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[SiteAttributeSet] DROP CONSTRAINT [FK_SiteSiteAttribute];
GO
IF OBJECT_ID(N'[mobileS].[FK_SiteSetWishSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[WishSetSet] DROP CONSTRAINT [FK_SiteSetWishSet];
GO
IF OBJECT_ID(N'[mobileS].[FK_SiteSetFriendSiteSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[FriendSiteSetSet] DROP CONSTRAINT [FK_SiteSetFriendSiteSet];
GO
IF OBJECT_ID(N'[mobileS].[FK_GoodSetNotAvailableSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[NotAvailableSetSet] DROP CONSTRAINT [FK_GoodSetNotAvailableSet];
GO
IF OBJECT_ID(N'[mobileS].[FK_GoodSetRentSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[RentSetSet] DROP CONSTRAINT [FK_GoodSetRentSet];
GO
IF OBJECT_ID(N'[mobileS].[FK_UserSetRentSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[RentSetSet] DROP CONSTRAINT [FK_UserSetRentSet];
GO
IF OBJECT_ID(N'[mobileS].[FK_WishSetCriterionSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[CriterionSetSet] DROP CONSTRAINT [FK_WishSetCriterionSet];
GO
IF OBJECT_ID(N'[mobileS].[FK_UserSetGoodSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[GoodSet] DROP CONSTRAINT [FK_UserSetGoodSet];
GO
IF OBJECT_ID(N'[mobileS].[FK_UserSetWishSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[WishSetSet] DROP CONSTRAINT [FK_UserSetWishSet];
GO
IF OBJECT_ID(N'[mobileS].[FK_SiteAttributeSetCriterionSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[CriterionSetSet] DROP CONSTRAINT [FK_SiteAttributeSetCriterionSet];
GO
IF OBJECT_ID(N'[mobileS].[FK_UserSetInnapropiate]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[InnapropiateSetSet] DROP CONSTRAINT [FK_UserSetInnapropiate];
GO
IF OBJECT_ID(N'[mobileS].[FK_ContentSetInnapropiateSet]', 'F') IS NOT NULL
    ALTER TABLE [mobileS].[InnapropiateSetSet] DROP CONSTRAINT [FK_ContentSetInnapropiateSet];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[mobileS].[AttributeSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[AttributeSet];
GO
IF OBJECT_ID(N'[mobileS].[ContentSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[ContentSet];
GO
IF OBJECT_ID(N'[mobileS].[GoodSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[GoodSet];
GO
IF OBJECT_ID(N'[mobileS].[LikeSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[LikeSet];
GO
IF OBJECT_ID(N'[mobileS].[SiteAttributeSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[SiteAttributeSet];
GO
IF OBJECT_ID(N'[mobileS].[SiteSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[SiteSet];
GO
IF OBJECT_ID(N'[mobileS].[UserSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[UserSet];
GO
IF OBJECT_ID(N'[mobileS].[NotAvailableSetSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[NotAvailableSetSet];
GO
IF OBJECT_ID(N'[mobileS].[RentSetSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[RentSetSet];
GO
IF OBJECT_ID(N'[mobileS].[WishSetSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[WishSetSet];
GO
IF OBJECT_ID(N'[mobileS].[CriterionSetSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[CriterionSetSet];
GO
IF OBJECT_ID(N'[mobileS].[FriendSiteSetSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[FriendSiteSetSet];
GO
IF OBJECT_ID(N'[mobileS].[InnapropiateSetSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[InnapropiateSetSet];
GO
IF OBJECT_ID(N'[mobileS].[ConfigurationSet]', 'U') IS NOT NULL
    DROP TABLE [mobileS].[ConfigurationSet];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'AttributeSet'
CREATE TABLE [mobileS].[AttributeSet] (
    [id] int IDENTITY(1,1) NOT NULL,
    [Value] nvarchar(max)  NOT NULL,
    [GoodId] int  NOT NULL,
    [SiteAttributeId] int  NOT NULL
);
GO

-- Creating table 'ContentSet'
CREATE TABLE [mobileS].[ContentSet] (
    [id] int IDENTITY(1,1) NOT NULL,
    [Url] nvarchar(max)  NOT NULL,
    [GoodId] int  NOT NULL,
    [Comment] nvarchar(max)  NOT NULL,
    [Date] datetime  NOT NULL,
    [UserId] int  NOT NULL,
    [Active] bit  NOT NULL
);
GO

-- Creating table 'GoodSet'
CREATE TABLE [mobileS].[GoodSet] (
    [id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Image] varbinary(max)  NULL,
    [BigImage] varbinary(max)  NULL,
    [PriceDay] decimal(18,2)  NOT NULL,
    [Latitude] decimal(18,10)  NOT NULL,
    [Longitude] decimal(18,10)  NOT NULL,
    [SiteId] int  NOT NULL,
    [Likes] int  NOT NULL,
    [UserId] int  NOT NULL,
    [CreatedAt] datetime  NOT NULL
);
GO

-- Creating table 'LikeSet'
CREATE TABLE [mobileS].[LikeSet] (
    [id] bigint IDENTITY(1,1) NOT NULL,
    [UserId] int  NOT NULL,
    [GoodId] int  NOT NULL,
    [UserSet_id] int  NOT NULL
);
GO

-- Creating table 'SiteAttributeSet'
CREATE TABLE [mobileS].[SiteAttributeSet] (
    [id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [SiteId] int  NOT NULL
);
GO

-- Creating table 'SiteSet'
CREATE TABLE [mobileS].[SiteSet] (
    [id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Logo] varbinary(max)  NULL,
    [Style] nvarchar(max)  NOT NULL,
    [GoodType] nvarchar(max)  NOT NULL,
    [AdminId] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'UserSet'
CREATE TABLE [mobileS].[UserSet] (
    [id] int  NOT NULL,
    [Email] nvarchar(max)  NULL,
    [SocialId] nvarchar(max)  NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Infractions] int  NOT NULL,
    [Active] bit  NOT NULL
);
GO

-- Creating table 'NotAvailableSetSet'
CREATE TABLE [mobileS].[NotAvailableSetSet] (
    [id] bigint IDENTITY(1,1) NOT NULL,
    [GoodId] int  NOT NULL,
    [Start] datetime  NOT NULL,
    [Finish] datetime  NOT NULL
);
GO

-- Creating table 'RentSetSet'
CREATE TABLE [mobileS].[RentSetSet] (
    [id] bigint IDENTITY(1,1) NOT NULL,
    [GoodId] int  NOT NULL,
    [Price] decimal(18,10)  NOT NULL,
    [UserId] int  NOT NULL,
    [Start] datetime  NOT NULL,
    [Finish] datetime  NOT NULL,
    [Token] nvarchar(max)  NOT NULL,
    [Active] bit  NOT NULL
);
GO

-- Creating table 'WishSetSet'
CREATE TABLE [mobileS].[WishSetSet] (
    [id] bigint IDENTITY(1,1) NOT NULL,
    [Latitude] decimal(18,10)  NOT NULL,
    [Longitude] decimal(18,10)  NOT NULL,
    [Radius] decimal(18,10)  NOT NULL,
    [SiteId] int  NOT NULL,
    [UserId] int  NOT NULL
);
GO

-- Creating table 'CriterionSetSet'
CREATE TABLE [mobileS].[CriterionSetSet] (
    [id] bigint IDENTITY(1,1) NOT NULL,
    [WishId] bigint  NOT NULL,
    [Value] nvarchar(max)  NOT NULL,
    [SiteAttributeId] int  NOT NULL
);
GO

-- Creating table 'FriendSiteSetSet'
CREATE TABLE [mobileS].[FriendSiteSetSet] (
    [id] int IDENTITY(1,1) NOT NULL,
    [Url] nvarchar(max)  NOT NULL,
    [SiteId] int  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Keyword] nvarchar(max)  NULL
);
GO

-- Creating table 'InnapropiateSetSet'
CREATE TABLE [mobileS].[InnapropiateSetSet] (
    [id] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NOT NULL,
    [ContentId] int  NOT NULL
);
GO

-- Creating table 'ConfigurationSet'
CREATE TABLE [mobileS].[ConfigurationSet] (
    [id] int IDENTITY(1,1) NOT NULL,
    [InapropiateMax] int  NOT NULL,
    [InfractionMax] int  NOT NULL,
    [RankedGoodsMax] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [id] in table 'AttributeSet'
ALTER TABLE [mobileS].[AttributeSet]
ADD CONSTRAINT [PK_AttributeSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'ContentSet'
ALTER TABLE [mobileS].[ContentSet]
ADD CONSTRAINT [PK_ContentSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'GoodSet'
ALTER TABLE [mobileS].[GoodSet]
ADD CONSTRAINT [PK_GoodSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'LikeSet'
ALTER TABLE [mobileS].[LikeSet]
ADD CONSTRAINT [PK_LikeSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'SiteAttributeSet'
ALTER TABLE [mobileS].[SiteAttributeSet]
ADD CONSTRAINT [PK_SiteAttributeSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'SiteSet'
ALTER TABLE [mobileS].[SiteSet]
ADD CONSTRAINT [PK_SiteSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'UserSet'
ALTER TABLE [mobileS].[UserSet]
ADD CONSTRAINT [PK_UserSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'NotAvailableSetSet'
ALTER TABLE [mobileS].[NotAvailableSetSet]
ADD CONSTRAINT [PK_NotAvailableSetSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'RentSetSet'
ALTER TABLE [mobileS].[RentSetSet]
ADD CONSTRAINT [PK_RentSetSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'WishSetSet'
ALTER TABLE [mobileS].[WishSetSet]
ADD CONSTRAINT [PK_WishSetSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'CriterionSetSet'
ALTER TABLE [mobileS].[CriterionSetSet]
ADD CONSTRAINT [PK_CriterionSetSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'FriendSiteSetSet'
ALTER TABLE [mobileS].[FriendSiteSetSet]
ADD CONSTRAINT [PK_FriendSiteSetSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'InnapropiateSetSet'
ALTER TABLE [mobileS].[InnapropiateSetSet]
ADD CONSTRAINT [PK_InnapropiateSetSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'ConfigurationSet'
ALTER TABLE [mobileS].[ConfigurationSet]
ADD CONSTRAINT [PK_ConfigurationSet]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [GoodId] in table 'AttributeSet'
ALTER TABLE [mobileS].[AttributeSet]
ADD CONSTRAINT [FK_GoodAttribute]
    FOREIGN KEY ([GoodId])
    REFERENCES [mobileS].[GoodSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GoodAttribute'
CREATE INDEX [IX_FK_GoodAttribute]
ON [mobileS].[AttributeSet]
    ([GoodId]);
GO

-- Creating foreign key on [SiteAttributeId] in table 'AttributeSet'
ALTER TABLE [mobileS].[AttributeSet]
ADD CONSTRAINT [FK_SiteAttributeAttribute]
    FOREIGN KEY ([SiteAttributeId])
    REFERENCES [mobileS].[SiteAttributeSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SiteAttributeAttribute'
CREATE INDEX [IX_FK_SiteAttributeAttribute]
ON [mobileS].[AttributeSet]
    ([SiteAttributeId]);
GO

-- Creating foreign key on [GoodId] in table 'ContentSet'
ALTER TABLE [mobileS].[ContentSet]
ADD CONSTRAINT [FK_GoodContent]
    FOREIGN KEY ([GoodId])
    REFERENCES [mobileS].[GoodSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GoodContent'
CREATE INDEX [IX_FK_GoodContent]
ON [mobileS].[ContentSet]
    ([GoodId]);
GO

-- Creating foreign key on [UserId] in table 'ContentSet'
ALTER TABLE [mobileS].[ContentSet]
ADD CONSTRAINT [FK_UserContent]
    FOREIGN KEY ([UserId])
    REFERENCES [mobileS].[UserSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserContent'
CREATE INDEX [IX_FK_UserContent]
ON [mobileS].[ContentSet]
    ([UserId]);
GO

-- Creating foreign key on [GoodId] in table 'LikeSet'
ALTER TABLE [mobileS].[LikeSet]
ADD CONSTRAINT [FK_GoodLike]
    FOREIGN KEY ([GoodId])
    REFERENCES [mobileS].[GoodSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GoodLike'
CREATE INDEX [IX_FK_GoodLike]
ON [mobileS].[LikeSet]
    ([GoodId]);
GO

-- Creating foreign key on [UserSet_id] in table 'LikeSet'
ALTER TABLE [mobileS].[LikeSet]
ADD CONSTRAINT [FK_UserSetLikeSet]
    FOREIGN KEY ([UserSet_id])
    REFERENCES [mobileS].[UserSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserSetLikeSet'
CREATE INDEX [IX_FK_UserSetLikeSet]
ON [mobileS].[LikeSet]
    ([UserSet_id]);
GO

-- Creating foreign key on [SiteId] in table 'GoodSet'
ALTER TABLE [mobileS].[GoodSet]
ADD CONSTRAINT [FK_SiteGood]
    FOREIGN KEY ([SiteId])
    REFERENCES [mobileS].[SiteSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SiteGood'
CREATE INDEX [IX_FK_SiteGood]
ON [mobileS].[GoodSet]
    ([SiteId]);
GO

-- Creating foreign key on [SiteId] in table 'SiteAttributeSet'
ALTER TABLE [mobileS].[SiteAttributeSet]
ADD CONSTRAINT [FK_SiteSiteAttribute]
    FOREIGN KEY ([SiteId])
    REFERENCES [mobileS].[SiteSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SiteSiteAttribute'
CREATE INDEX [IX_FK_SiteSiteAttribute]
ON [mobileS].[SiteAttributeSet]
    ([SiteId]);
GO

-- Creating foreign key on [SiteId] in table 'WishSetSet'
ALTER TABLE [mobileS].[WishSetSet]
ADD CONSTRAINT [FK_SiteSetWishSet]
    FOREIGN KEY ([SiteId])
    REFERENCES [mobileS].[SiteSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SiteSetWishSet'
CREATE INDEX [IX_FK_SiteSetWishSet]
ON [mobileS].[WishSetSet]
    ([SiteId]);
GO

-- Creating foreign key on [SiteId] in table 'FriendSiteSetSet'
ALTER TABLE [mobileS].[FriendSiteSetSet]
ADD CONSTRAINT [FK_SiteSetFriendSiteSet]
    FOREIGN KEY ([SiteId])
    REFERENCES [mobileS].[SiteSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SiteSetFriendSiteSet'
CREATE INDEX [IX_FK_SiteSetFriendSiteSet]
ON [mobileS].[FriendSiteSetSet]
    ([SiteId]);
GO

-- Creating foreign key on [GoodId] in table 'NotAvailableSetSet'
ALTER TABLE [mobileS].[NotAvailableSetSet]
ADD CONSTRAINT [FK_GoodSetNotAvailableSet]
    FOREIGN KEY ([GoodId])
    REFERENCES [mobileS].[GoodSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GoodSetNotAvailableSet'
CREATE INDEX [IX_FK_GoodSetNotAvailableSet]
ON [mobileS].[NotAvailableSetSet]
    ([GoodId]);
GO

-- Creating foreign key on [GoodId] in table 'RentSetSet'
ALTER TABLE [mobileS].[RentSetSet]
ADD CONSTRAINT [FK_GoodSetRentSet]
    FOREIGN KEY ([GoodId])
    REFERENCES [mobileS].[GoodSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GoodSetRentSet'
CREATE INDEX [IX_FK_GoodSetRentSet]
ON [mobileS].[RentSetSet]
    ([GoodId]);
GO

-- Creating foreign key on [UserId] in table 'RentSetSet'
ALTER TABLE [mobileS].[RentSetSet]
ADD CONSTRAINT [FK_UserSetRentSet]
    FOREIGN KEY ([UserId])
    REFERENCES [mobileS].[UserSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserSetRentSet'
CREATE INDEX [IX_FK_UserSetRentSet]
ON [mobileS].[RentSetSet]
    ([UserId]);
GO

-- Creating foreign key on [WishId] in table 'CriterionSetSet'
ALTER TABLE [mobileS].[CriterionSetSet]
ADD CONSTRAINT [FK_WishSetCriterionSet]
    FOREIGN KEY ([WishId])
    REFERENCES [mobileS].[WishSetSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_WishSetCriterionSet'
CREATE INDEX [IX_FK_WishSetCriterionSet]
ON [mobileS].[CriterionSetSet]
    ([WishId]);
GO

-- Creating foreign key on [UserId] in table 'GoodSet'
ALTER TABLE [mobileS].[GoodSet]
ADD CONSTRAINT [FK_UserSetGoodSet]
    FOREIGN KEY ([UserId])
    REFERENCES [mobileS].[UserSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserSetGoodSet'
CREATE INDEX [IX_FK_UserSetGoodSet]
ON [mobileS].[GoodSet]
    ([UserId]);
GO

-- Creating foreign key on [UserId] in table 'WishSetSet'
ALTER TABLE [mobileS].[WishSetSet]
ADD CONSTRAINT [FK_UserSetWishSet]
    FOREIGN KEY ([UserId])
    REFERENCES [mobileS].[UserSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserSetWishSet'
CREATE INDEX [IX_FK_UserSetWishSet]
ON [mobileS].[WishSetSet]
    ([UserId]);
GO

-- Creating foreign key on [SiteAttributeId] in table 'CriterionSetSet'
ALTER TABLE [mobileS].[CriterionSetSet]
ADD CONSTRAINT [FK_SiteAttributeSetCriterionSet]
    FOREIGN KEY ([SiteAttributeId])
    REFERENCES [mobileS].[SiteAttributeSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SiteAttributeSetCriterionSet'
CREATE INDEX [IX_FK_SiteAttributeSetCriterionSet]
ON [mobileS].[CriterionSetSet]
    ([SiteAttributeId]);
GO

-- Creating foreign key on [UserId] in table 'InnapropiateSetSet'
ALTER TABLE [mobileS].[InnapropiateSetSet]
ADD CONSTRAINT [FK_UserSetInnapropiate]
    FOREIGN KEY ([UserId])
    REFERENCES [mobileS].[UserSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserSetInnapropiate'
CREATE INDEX [IX_FK_UserSetInnapropiate]
ON [mobileS].[InnapropiateSetSet]
    ([UserId]);
GO

-- Creating foreign key on [ContentId] in table 'InnapropiateSetSet'
ALTER TABLE [mobileS].[InnapropiateSetSet]
ADD CONSTRAINT [FK_ContentSetInnapropiateSet]
    FOREIGN KEY ([ContentId])
    REFERENCES [mobileS].[ContentSet]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ContentSetInnapropiateSet'
CREATE INDEX [IX_FK_ContentSetInnapropiateSet]
ON [mobileS].[InnapropiateSetSet]
    ([ContentId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------